<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>菜单管理</title>
    <meta name="decorator" content="nblank"/>
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
</head>
<body>
<div class="content container">
    <h2 class="page-title">菜单管理<small> 菜单添加</small></h2>
<section class="widget widget-tabs widget-table-overflow ">
    <header>
        <ul class="nav nav-tabs">
            <li><a href="${ctx}/sys/menu/">菜单列表</a></li>
            <li class="active"><a href="javascript:;">菜单<shiro:hasPermission name="sys:menu:edit">${not empty menu.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sys:menu:edit">查看</shiro:lacksPermission></a></li>
        </ul>
    </header>
        <div class="body tab-content">
            <form:form id="inputForm" modelAttribute="menu" action="${ctx}/sys/menu/save" method="post" class="form-horizontal">
                <form:hidden path="id"/>
                <sys:message content="${message}"/>
                <div class="form-group">
                    <label class="control-label col-sm-4">上级菜单:</label>
                    <div class="col-sm-4">
                        <sys:treeselect id="menu" name="parent.id" value="${menu.parent.id}" labelName="parent.name"
                                        labelValue="${menu.parent.name}"
                                        title="菜单" url="/sys/menu/treeData" extId="${menu.id}" cssClass="form-control input-transparent"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4"><span><span style="color:red;">*</span></span> 名称:</label>
                    <div class="col-sm-4">
                        <form:input path="name" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
                        <%--<span class="help-inline"><span style="color:red;">*</span></span>--%>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">链接:</label>
                    <div class="col-sm-4">
                        <form:input path="href" htmlEscape="false" maxlength="2000" class="form-control input-transparent"/>
                        <span class="help-inline">点击菜单跳转的页面</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">目标:</label>
                    <div class="col-sm-4">
                        <form:input path="target" htmlEscape="false" maxlength="10" class="form-control input-transparent"/>
                        <span class="help-inline">链接地址打开的目标窗口，默认：mainFrame</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">图标:</label>
                    <div class="col-sm-4">
                        <sys:iconselect id="icon" name="icon" value="${menu.icon}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">排序:</label>
                    <div class="col-sm-4">
                        <form:input path="sort" htmlEscape="false" maxlength="50" class="form-control input-transparent"/>
                        <span class="help-inline">排列顺序，升序。</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">可见:</label>
                    <div class="col-sm-4">
                        <div class="radio">
                            <form:radiobuttons path="isShow" items="${fns:getDictList('show_hide')}" itemLabel="label"
                                           itemValue="value" htmlEscape="false" class="mr-lg"/>
                        </div>
                        <span class="help-inline">该菜单或操作是否显示到系统菜单中</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">权限标识:</label>
                    <div class="col-sm-4">
                        <form:input path="permission" htmlEscape="false" maxlength="100" class="form-control input-transparent"/>
                        <span class="help-inline">控制器中定义的权限标识，如：@RequiresPermissions("权限标识")</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-4">备注:</label>
                    <div class="col-sm-4">
                        <form:textarea path="remarks" htmlEscape="false" rows="3" maxlength="200" class="form-control input-transparent"/>
                    </div>
                </div>
                <div class="form-actions">
                    <div class="text-align-center">
                        <input id="btnCancel" class="btn btn-default" type="button" style="margin-left: -50px;min-width:100px;" value="返 回" onclick="history.go(-1)"/>
                        <input id="btnSubmit" class="btn btn-primary" style="margin-left:50px;min-width:100px;" type="submit" value="保 存"/>&nbsp;
                    </div>
                </div>
            </form:form>
        </div>
    </section>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#name").focus();
        $("#inputForm").validate({
            submitHandler: function (form) {
                loading('正在提交，请稍等...');
                form.submit();
            },
            errorContainer: "#messageBox",
            errorPlacement: function (error, element) {
                $("#messageBox").text("输入有误，请先更正。");
                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                    error.appendTo(element.parent().parent());
                } else {
                    error.insertAfter(element);
                }
            }
        });
    });
</script>
</body>
</html>
